// import com.alibaba.druid.DbType_ptr;
// import com.alibaba.druid.FastsqlException;
// import com.alibaba.druid.sql.SQLUtils;
// import com.alibaba.druid.sql.ast.SQLExpr;
// import com.alibaba.druid.sql.ast.SQLObject_ptr;
// import com.alibaba.druid.sql.ast.expr.*;
// import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
// import com.alibaba.druid.sql.ast.statement.SQLSelect;
// import com.alibaba.druid.sql.ast.statement.SQLSelectItem;
// import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
// import com.alibaba.druid.sql.dialect.db2.visitor.DB2EvalVisitor;
// import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlEvalVisitorImpl;
// import com.alibaba.druid.sql.dialect.oracle.visitor.OracleEvalVisitor;
// import com.alibaba.druid.sql.dialect.postgresql.visitor.PGEvalVisitor;
// import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerEvalVisitor;
// import com.alibaba.druid.sql.visitor.functions.*;
// import com.alibaba.druid.util.HexBin;
// import com.alibaba.druid.util.Utils;
// import com.alibaba.druid.wall.spi.WallVisitorUtils;
// import com.alibaba.druid.wall.spi.WallVisitorUtils.WallConditionContext;

// import java.math.BigDecimal;
// import java.math.BigInteger;
// import java.text.ParseException;
// import java.text.SimpleDateFormat;
// import java.util.*;
// import java.util.regex.Pattern;

// import static com.alibaba.druid.sql.visitor.SQLEvalVisitor* .*;
#pragma once
#include <map>
#include "functions/Function.h"

class SQLEvalVisitorUtils
{
public:
  static bool __init;
  static bool init();
  
  static std::map<std::string, SQLFunction*> functions;

  static Object_ptr evalExpr(DbType_ptr dbType, string_ptr expr, Object_ptr parameters);

  static Object_ptr evalExpr(DbType_ptr dbType, string_ptr expr, Object_list_ptr parameters);

  static Object_ptr eval(DbType_ptr dbType, SQLObject_ptr sqlObject, Object_ptr parameters);

  static Object_ptr getValue(SQLObject_ptr sqlObject);

  static Object_ptr eval(DbType_ptr dbType, SQLObject_ptr sqlObject, Object_list_ptr parameters);

  static Object_ptr eval(DbType_ptr dbType, SQLObject_ptr sqlObject, Object_list_ptr parameters, bool throwError);

  static SQLEvalVisitor_ptr  createEvalVisitor(DbType_ptr dbType);

  static void registerBaseFunctions();

  static bool visit(SQLEvalVisitor*  visitor, SQLMethodInvokeExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLCharExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLHexExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLBinaryExpr_ptr x);

  static SQLExpr_ptr unwrap(SQLExpr_ptr expr);

  static bool visit(SQLEvalVisitor*  visitor, SQLBetweenExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLNullExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLCaseExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLInListExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLQueryExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLUnaryExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLBinaryOpExpr_ptr x);

  // @SuppressWarnings("rawtypes")
  static Object_ptr processValue(Object_ptr value);

  static bool isAlwayTrueLikePattern(SQLExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLNumericLiteralExpr_ptr x);

  static bool visit(SQLEvalVisitor*  visitor, SQLVariantRefExpr_ptr x);

  static BOOL_ptr castToBoolean(Object_ptr val);

  static string_ptr castToString(Object_ptr val);

  static char castToByte(Object_ptr val);

  static short castToShort(Object_ptr val);

  // @SuppressWarnings("rawtypes")
  static int castToInteger(Object_ptr val);

  // @SuppressWarnings("rawtypes")
  static long castToLong(Object_ptr val);

  static float castToFloat(Object_ptr val);

  static double castToDouble(Object_ptr val);

  static long long castToBigInteger(Object_ptr val);

  static double castToNumber(string_ptr val);

  static time_t castToDate(Object_ptr val);

  static time_t castToDate(string_ptr text);

  static double castToDecimal(Object_ptr val);

  static Object_ptr rightShift(Object_ptr a, Object_ptr b);

  static Object_ptr bitAnd(Object_ptr a, Object_ptr b);

  static Object_ptr bitOr(Object_ptr a, Object_ptr b);

  static Object_ptr div(Object_ptr a, Object_ptr b);

  static bool gt(Object_ptr a, Object_ptr b);

  static bool gteq(Object_ptr a, Object_ptr b);

  static bool lt(Object_ptr a, Object_ptr b);

  static bool lteq(Object_ptr a, Object_ptr b);

  static bool eq(Object_ptr a, Object_ptr b);

  static Object_ptr add(Object_ptr a, Object_ptr b);

  static Object_ptr sub(Object_ptr a, Object_ptr b);

  static Object_ptr multi(Object_ptr a, Object_ptr b);

  static bool like(string_ptr input, string_ptr pattern);

  static bool visit(SQLEvalVisitor*  visitor, SQLIdentifierExpr_ptr x);
};
